package sc.util;

/**
 * Provides a handful of functions that could be used by multiple indicators
 * 
 * @author Quentin Rossé
 *
 */
public class FinancialNumbers {
	
	/**
	 * Returns the true range
	 * 
	 * @param dayHigh highest value of the stock for the day
	 * @param dayLow lowest value of the stock for the day
	 * @param previousClose value of the stock at the previous close
	 * 
	 * @return the true range
	 */
	public static float trueRange(float dayHigh, 
			                      float dayLow, 
			                      float previousClose){	
		float tmp1 = Math.abs(dayHigh - dayLow);
		float tmp2 = Math.abs(dayHigh - previousClose);
		
		if(tmp1 > tmp2)
			tmp2 = Math.abs(previousClose - dayLow);
		else
			tmp1 = Math.abs(previousClose - dayLow);
		
		return Math.max(tmp1, tmp2);
	}

}
